# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - upstream patch for AArch64

# Contributor: Ronald van Haren <ronald.archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Mark Rosenstand <mark@archlinux.org>

pkgname=fuse2
pkgver=2.9.9
pkgrel=5
pkgdesc='Interface for userspace programs to export a filesystem to the Linux kernel'
url='https://github.com/libfuse/libfuse'
arch=('x86_64')
license=('GPL2')
depends=('glibc' 'fuse-common')
makedepends=('pkg-config')
provides=(fuse=$pkgver) # TODO: remove it once all packages start to use 'fuse2' name
replaces=('fuse')
conflicts=('fuse')
options=('!emptydirs')
source=(https://github.com/libfuse/libfuse/releases/download/fuse-$pkgver/fuse-$pkgver.tar.gz{,.asc}
	conditionally-define-closefrom.patch
        https://github.com/libfuse/libfuse/commit/914871b20a901e3e1e981c92bc42b1c93b7ab81b.patch)
sha1sums=('943ba651b14bc4a3c6fd959ed4b8c04f4a59032d'
          'SKIP'
          '90750cd0839c1ee427314241f9ea5f054c3335d8'
          '0eac15084300e71129eaf3f39b8b7b25a6c18cab')
sha512sums=('3d82fafd04f2924299bb09d2bb144935fa004a43fb9a6568e2e1cc5a60fded2efa1711029a0d7f12b3e6e4501f7217f2ee3545646d89da8dece083cb390f23e2'
            'SKIP'
            '0836d1693bea203b562a86c992107ee48766f41bb05a31e9af41009d2270ac84d7881aa5bc2a11ed478cd03985876aca5080341ddea701a12a630a36e1b1a80b'
            '6615563894b3c402468db975c227a531a225848a3ce3e802d25081480d356b53b64ce7ccf60083b7d7e069cb553f4add71f113f119d3a7d02888fee96fc74a73')
validpgpkeys=(ED31791B2C5C1613AF388B8AD113FCAC3C4E599F) # Nikolaus Rath <Nikolaus@rath.org>

prepare() {
  cd fuse-$pkgver
  patch -p1 -i ../914871b20a901e3e1e981c92bc42b1c93b7ab81b.patch
  patch -Np1 -i ${srcdir}/conditionally-define-closefrom.patch
  autoreconf -i
}

build() {
  cd fuse-$pkgver

  UDEV_RULES_PATH=/usr/lib/udev/rules.d MOUNT_FUSE_PATH=/usr/bin ./configure --prefix=/usr --libdir=/usr/lib --enable-lib --enable-util --disable-example
  make
}

package() {
  cd fuse-$pkgver

  make DESTDIR="${pkgdir}" install

  # Remove init script in wrong path
  # Don't add our own for now, as fusectl fs oopses on 2.6.18
  rm -r "${pkgdir}"/etc/init.d

  # static device nodes are handled by udev
  rm -r "${pkgdir}"/dev
}
